module AuthenticatedTestHelper
  # Sets the current accounts in the session from the accounts fixtures.
  def login_as(accounts)
    @request.session[:accounts_id] = accounts ? (accounts.is_a?(Accounts) ? accounts.id : accounts(accounts).id) : nil
  end

  def authorize_as(accounts)
    @request.env["HTTP_AUTHORIZATION"] = accounts ? ActionController::HttpAuthentication::Basic.encode_credentials(accounts(accounts).login, 'monkey') : nil
  end
  
end
